{% extends "base.html" %}
{% block title %}{% endblock %}
{% block content %}
<div class="layui-layout layui-layout-admin" >
    <div class="layui-header" >
        <div class="laui-logo" ><h3 style="float:left;left:20px;padding:15px;margin-top:5px;color:white">Undefined-Test 测试管理平台V1.0 作者：文青山 微信qwenTest</h3></div>
        <ul class="layui-nav layui-layout-right" lay-filter="my">
            <li class="layui-nav-item" style="float:right;right:30px">
                <a href="javascript:;">我</a>
                <dl class="layui-nav-child" >
                    <dd><a href="javascript:;" >退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                  <li class="layui-nav-item layui-nav-itemed" lay-id="id-index" >
                    <a href="javascript:;" >统筹管理</a>
                      <dl class="layui-nav-child">
                        <dd><a href="javascript:;" class="layui-this">信息统计</a></dd>
                          <dd><a href="javascript:;" >计划管理</a></dd>
                    </dl>
                  </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;" >测试用例管理</a>
                      <dl class="layui-nav-child">
                        <dd><a href="javascript:;" >执行测试用例</a></dd>
                          <dd><a href="javascript:;" >在线编辑用例</a></dd>
                          <dd><a href="javascript:;" >导入测试用例</a></dd>
                          <dd><a href="javascript:;" >测试结果分布</a></dd>
                          <dd><a href="javascript:;" >历史结果查询</a></dd>

                    </dl>
                  </li>
                  <li class="layui-nav-item " lay-id="nav-api-case-index" >
                    <a href="javascript:;" >接口测试管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" >接口测试案例</a></dd>
                        <dd><a href="javascript:;">接口测试计划</a></dd>
                        <dd><a href="javascript:;">接口模块管理</a></dd>
                        <dd><a href="javascript:;">接口参数管理</a></dd>
                        <dd><a href="javascript:;">接口结果查询</a></dd>
                    </dl>
                  </li>
                  <li class="layui-nav-item">
                    <a href="javascript:;">自动化压测管理</a>
                    <dl class="layui-nav-child">
                      <dd><a href="javascript:;">压测案例管理</a></dd>
                      <dd><a href="javascript:;">压测结果查询</a></dd>
                    </dl>
                  </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">信息维护</a>
                        <dl class="layui-nav-child">
                          <dd><a href="javascript:;" id="projectManage">项目管理</a></dd>
                            <dd><a href="javascript:;" id="userLink">用户管理</a></dd>
                        </dl>
                  </li>
            </ul>
        </div>
    </div>
    <div class="layui-body" >
        <div style="padding:15px;margin-top:-20px">
            <div class="layui-tab" lay-filter="demo" lay-allowclose="true">
                <ul class="layui-tab-title">
                    <li class="layui-this" lay-id="lay_index" style="color:#FF5722">信息统计<i class="layui-icon layui-icon-edit" style="font-size:20px;color:#FF5277"></i></li>
                </ul>
                <div class="layui-tab-content" style="padding:5px;margin-top:10px;">
                    <div class="layui-tab-item layui-show" id="lay-content">
                        <iframe id="tabIFrame0"  src="/totalHtml?token={{token}}&openId={{openId}}" style="scrolling:no;frameborder:0;border:none;width:{{winWidth}}px;height:{{winHeight}}px"></iframe>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<script>

layui.use(['element'], function(){
  var $= layui.jquery;
  var element = layui.element;
  userInfo = layui.data('test').UserInfo;
  if(userInfo == undefined){
     window.location.href="/login";
  }
  role = userInfo.role;

  if(role==0 ||role == "0"){
     $("#userLink").hide();
     $("#projectManage").hide();
  }
  //点击nav，打开tab
  function setFramHeight(id){
     var winWidth = $(window).width() - 250;
     var winHeight = $(window).height();
     frameId = '#'+id+'_frame';
     $(frameId).height(winHeight);
     $(frameId).width(winWidth);
     $('.layui-tab-content').css('overflow','inherit');
     $('.layui-tab-content').height(winHeight);

  }

  function click_link(id,name,url){
        var count= $('li[lay-id="'+id+'"]').length;
        if(count == 0){
            content = '<iframe id="'+id+'_frame" src="'+url+'" style="scrolling:no;frameborder:0;border:none"></iframe>';
            name = name+'<i class="layui-icon layui-icon-edit" style="font-size:20px;color:#FF5277"></i>';
            element.tabAdd("demo",{title:name,content:content,id:id});
            element.tabChange("demo",id);
        }else{
            element.tabChange("demo",id);
        }
        setFramHeight(id);
        setClassNav(id);
  }
  //切换后将其它呈选中的nav，取消layui-this
  function setClassNav(lay_id){
       $('.layui-tab-title>li').css('color','black');
       $('.layui-icon.layui-icon-edit').hide();
       $(".layui-class").removeClass("layui-this");

       $('li[lay-id="'+lay_id+'"]').addClass("layui-this");
       $('li[lay-id="'+lay_id+'"]').css('color','#FF5722');
       $('li.layui-this>i.layui-icon.layui-icon-edit').show();
  }
   element.on('nav(my)', function(){
      var value = this.textContent;
        if(value == "退出"){
            token = layui.data('test').UserInfo.token;
            openId = layui.data('test').UserInfo.openId;
            $.ajax({
                        //发出请求
                        type:"GET",
                        url:"/logout",
                        contentType: 'application/json; charset=utf-8',
                        dataType:"json",
                        async:false,
                        data:{"token":token,"openId":openId},
                        success: function(result){

                        }
            });
            window.location.href = "/login";
        }

   });

  //监听Tab切换，以改变地址hash值
  element.on('nav(test)', function(){
        //$('.li[lay-id="id-index"]').addClass("layui-this");
        var value = this.textContent;
        if(value == "接口测试案例"){
            click_link('tab-api-case-index','接口测试案例','/api/case/index?token={{token}}&openId={{openId}}');
        } else if(value == "接口测试计划"){
            click_link('tab-api-case-plan-index','接口测试计划','/case/plan/index?token={{token}}&openId={{openId}}');

        } else if(value == "接口参数管理"){
            click_link('tab-api-case-params-index','接口参数管理','/api/case/params/index?token={{token}}&openId={{openId}}');
        } else if(value == "接口结果查询"){
            click_link('tab-api-case-result-index','接口结果查询','/api/case/result/index?token={{token}}&openId={{openId}}');
        } else if(value == "压测案例管理"){
            click_link('tab-api-load-index','压测案例管理','/load/index');
        }else if(value == "压测结果查询"){
            click_link('tab-api-load-result-index','压测结果查询','/load/result');
        }else if(value == "项目管理"){
            click_link('tab-pr-index','项目管理','/project/index');
        }else if(value == "接口模块管理"){
            click_link('tab-md-index','接口模块管理','/moudle/index?token={{token}}&openId={{openId}}');
        }else if(value == "信息统计"){
            click_link('lay_index','信息统计','/totalHtml?token={{token}}&openId={{openId}}');
        }else if(value == "在线编辑用例"){
            click_link('tab_base_case_editor','在线编辑用例','/basecase/index/1?token={{token}}&openId={{openId}}');
        }else if(value == "导入测试用例"){
            click_link('tab_base_case_import','导入测试用例','/basecase/import/index?token={{token}}&openId={{openId}}');
        }else if(value == "执行测试用例"){
            click_link('tab_base_case_do','执行测试用例','/basecase/do/index?token={{token}}&openId={{openId}}');
        }else if(value == "历史结果查询"){
            click_link('tab_base_case_his_result','历史结果查询','/basecase/case/hisResult?token={{token}}&openId={{openId}}');
        }else if(value == "测试结果分布"){
            click_link('tab_base_case_his_sys','测试结果分布','/basecase/case/hisResult/sys?token={{token}}&openId={{openId}}');
        }else if(value == "计划管理"){
            click_link('tab_case_plan','计划管理','/casePlan/index?token={{token}}&openId={{openId}}');
        }else if(value == "用户管理"){
            click_link('tab_user','用户管理','/user/index');
        }

  });
  element.on('tab(demo)', function(){
      var value = this.textContent;

      if(value == "接口测试案例ဆ"){
            setClassNav('tab-api-case-index');
        } else if(value == "接口测试计划ဆ"){
            setClassNav('tab-api-case-plan-index');

        } else if(value == "接口参数管理ဆ"){
            setClassNav('tab-api-case-params-index');
        } else if(value == "接口结果查询ဆ"){
            setClassNav('tab-api-case-result-index');
        } else if(value == "压测案例管理ဆ"){
            setClassNav('tab-api-load-index');
        }else if(value == "压测结果查询ဆ"){
            setClassNav('tab-api-load-result-index');
        }else if(value == "项目管理ဆ"){
            setClassNav('tab-pr-index');
        }else if(value == "接口模块管理ဆ"){
            setClassNav('tab-md-index');
        }else if(value == "首页ဆ"){
            setClassNav('lay_index');
        }else if(value == "在线编辑用例ဆ"){
            setClassNav('tab_base_case_editor');
        }else if(value == "导入测试用例ဆ"){
            setClassNav('tab_base_case_import');
        }else if(value == "执行测试用例ဆ"){
            setClassNav('tab_base_case_do');
        }else if(value == "历史结果查询ဆ"){
            setClassNav('tab_base_case_his_result');
        }else if(value == "测试结果分布ဆ"){
            setClassNav('tab_base_case_his_sys');
        }else if(value == "计划管理ဆ"){
            setClassNav('tab_case_plan');
        }else if(value == "用户管理ဆ"){
            setClassNav('tab_user');
        }

  });
});
</script>
{% endblock %}